package caixindemo.colin.com.caixindemo.adapter;

import android.app.Activity;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.view.ViewGroup;

import java.util.List;

import caixindemo.colin.com.caixindemo.R;

import static caixindemo.colin.com.caixindemo.R.id.recycler_view;

/**
 * Created by Administrator on 2017/3/31.
 */

public class ListRecyclerViewAdapter extends BaseAdapter<String> {
    public ListRecyclerViewAdapter(Activity activity, List<String> itemList) {
        super(activity, itemList);
    }

    @Override
    public View getView(int position, View convertView, ViewGroup viewGroup) {
        ViewHolder viewHolder = null;
        if (convertView==null){
            viewHolder = new ViewHolder();
            convertView = layoutInflater.inflate(R.layout.item_main_recycler,viewGroup,false);
            viewHolder.recycler_view = (RecyclerView) convertView.findViewById(recycler_view);
            convertView.setTag(viewHolder);
        }else {
            viewHolder = (ViewHolder) convertView.getTag();
        }
        viewHolder.recycler_view.setLayoutManager(new LinearLayoutManager(activity, RecyclerView.HORIZONTAL, false));
        viewHolder.recycler_view.setAdapter(new ImageAdapter());
        return convertView;
    }
    private class ViewHolder {
        RecyclerView recycler_view;
    }
}
